package util;

import java.util.HashMap;
import java.util.Map;

import net.sf.json.JSONObject;

public class WebsiteUtil {

	// 雅虎汇率查询
	// public static String lookup(String curNo) {
	// String url =
	// "http://download.finance.yahoo.com/d/quotes.csv?e=.csv&f=sl1d1t1&s=" +
	// curNo + "CNY=x";
	// String result = new String(HttpUtil.call(url));
	// String[] res = result.split(",");
	// String r = res[1].replaceAll("\"", "");
	// return r;
	// }

	// 极速域名查询
	public static Map<String, String> lookup(String domain) throws Exception {
		Map<String, String> map = new HashMap<String, String>();
		String url = "http://api.jisuapi.com/whois/query?appkey=dbea824396b1e280&domain=" + domain;
		String res = new HttpUtil().get(url, null);
		JSONObject json = JSONObject.fromObject(res);
		JSONObject resultarr = json.optJSONObject("result");
		String registrant = resultarr.getString("registrant");
		String sponsor = resultarr.getString("sponsor");
		String created = resultarr.getString("created");
		String expires = resultarr.getString("expires");
		map.put("owner", registrant + "|" + sponsor);
		map.put("register", created + "|" + expires);
		return map;
	}

	public static void main(String[] args) throws Exception {
		System.out.println(lookup("etonpay.com"));

	}
}
